package com.runlooker.runer.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class RunerDBOpenHelper extends SQLiteOpenHelper {
	private static final String tag = RunerDBOpenHelper.class.getSimpleName();
	private static final int VERSION = 1;
	private static RunerDBOpenHelper mRunerDBOpenHelper;
	public static final String DATABASE_NAME = "runer.db";// 创建数据库表

	public RunerDBOpenHelper(Context context) {
		this(context, DATABASE_NAME, null, VERSION);
	}

	public synchronized static RunerDBOpenHelper getInstance(Context context) {
		if (mRunerDBOpenHelper == null) {
			mRunerDBOpenHelper = new RunerDBOpenHelper(context);
		}
		return mRunerDBOpenHelper;
	}

	public RunerDBOpenHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// 创建联系人表
		db.execSQL(RunerTableSql.getRosterEntrySql());

		// 创建联系人信息表
		db.execSQL(RunerTableSql.getPersonInfoSql());

		// 创建消息信息表
		db.execSQL(RunerTableSql.getMessageInfoSql());

		// 创建出席信息表
		db.execSQL(RunerTableSql.getPresenceTableSql());
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}
}
